<?php

namespace Model;
use Think\Model;

/**
* 
*/
class AuthModel extends Model
{
	function saveData($data){
//        $data= array(4) {
//            ["auth_name"] => string(0) ""
//            ["auth_pid"] => string(1) "0"
//            ["auth_c"] => string(0) ""
//            ["auth_a"] => string(0) ""
//            }

        $newid=$this->add($data);
        if($data['auth_pid']==0){
            $path=$newid;
        }else{
            $pinfo=$this->find($data['auth_pid']);
            $path=$pinfo['auth_path']."-".$newid;
        }
        //echo $path;
        $level=substr_count($path,'-');
        $sql="update sw_auth set auth_path='$path',auth_level='$level' WHERE auth_id='$newid'";
        $this->execute($sql);
    }
}
	

